package com.sscl.baselibrary.exts

import java.lang.reflect.ParameterizedType


/**
 * 获取泛型类型
 */
internal fun Any.getParameterizedType(): ParameterizedType {
    val genericSuperclass = javaClass.genericSuperclass
    return if (genericSuperclass is ParameterizedType) {
        genericSuperclass
    } else {
        javaClass.superclass.getParameterizedType()
    }
}

/**
 * 获取泛型类型
 */
internal fun Class<*>.getParameterizedType(): ParameterizedType {
    val genericSuperclass = this.genericSuperclass
    return if (genericSuperclass is ParameterizedType) {
        genericSuperclass
    } else {
        this.superclass.getParameterizedType()
    }
}